package com.truongnha.clienttn.business.service;

import java.util.List;

import android.content.Context;

import com.truongnha.clienttn.business.model.AttendModel;
import com.truongnha.clienttn.data.dao.AttendDAO;
import com.truongnha.clienttn.data.dao.CreateDatabase;
import com.truongnha.clienttn.data.entity.AttendEntity;
import com.truongnha.clienttn.data.sao.AttendSAO;

public class AttendService {
	Context context;

	public AttendService(Context context) {
		super();
		this.context = context;
	}

	public void getDataFromServer() {
		AttendSAO attendSAO = new AttendSAO(context);
		attendSAO.getDataFromServer();
	}

	public void getAll(List<AttendModel> result) {
		CreateDatabase db = new CreateDatabase(context);
		AttendDAO attendDAO = new AttendDAO(db.open());

		List<AttendEntity> list = attendDAO.getAll();
		for (AttendEntity attendEntity : list) {
			AttendModel attendModel = new AttendModel(attendEntity);
			result.add(0, attendModel);
		}

		db.close();
	}
}
